package com.zzb.demo.dao;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * @Author zzb
 * @Date 2024/11/19 12:09
 * @Version 1.0
 * @description
 */
//@Aspect
public class AnnoAdvice {

    @Pointcut("execution(* com.zzb.demo.service.impl.*.*(..))")
    public void pointCut() {}

    @Before("pointCut()")
    public void before() {
        System.out.println("前置通知");
    }
    @Around("pointCut()")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("环绕通知");
        System.out.println("开始执行方法......");
        Object result = proceedingJoinPoint.proceed(); // 执行目标方法
        return result;
    }

    @AfterReturning("pointCut()")
    public void afterReturning() {
        System.out.println("后置通知");
    }

    @After("pointCut()")
    public void after() {
        System.out.println("方法执行完成");
    }
}
